package com.woniuxy.threadmethods;

import com.woniuxy.untis.Sleep;
import lombok.extern.slf4j.Slf4j;

/**
 * <P> @Author: ideaAdmin
 * <P> TODO: Class
 * <P> TODO:
 * <P> Date: 2022/4/6:19:03
 * <P> Description:
 */
@Slf4j(topic = "c.DeadLock")
public class DeadLock {
    public static void main(String[] args) throws InterruptedException {
        Object o1 = new Object();
        Object o2 = new Object();

        new Thread(() -> {
            synchronized (o1) {
                Sleep.sleep(500);
                log.debug("t1->o1");
                synchronized (o2) {
                    log.debug("t1->o2");
                }
            }
        }, "t1").start();


        new Thread(() -> {
            synchronized (o2) {
                Sleep.sleep(500);
                log.debug("t2->o2");
                synchronized (o1) {
                    log.debug("t2->o2");
                }
            }
        }, "t2").start();

    }
}


